#include <iostream>


class Example
{
public:
	Example()
	{
	std::cout << "created Exmaple!" << std::endl;
    }
 
    Example(int x)
    {
	std::cout << "created Example with " << x << "!" << std::endl;
    }
};
 
class Entity
{
private:
    std::string m_name;
	Example m_Example;
 
public:

    Entity()
	{
		m_name = std::string ("unknown");
		m_Example = Example(8);
	}

    // 初始化列表，较少构造函数调用，提升性能
	Entity() : m_name("unkonwn"), m_Example(Example(8))
	{

	}
 
	Entity(const std::string& name)
	{
		m_name = name;
	}
 
	const std::string& GetName() const 
	{ 
		return m_name;
	}
 
};
 
int main(void)
{ 
	Entity e0;
/*output:
   created Exmaple!
   created Example with 8!
   
   不使用初始化化参数列表，会创建两个Example
   就像写在下面的一样。
    
public:
	Entity()
	{
        Example m_Example; //创建对象
		m_name = std::string ("unknown");
		m_Example = Example(8); //创建新的对象，覆盖之前的
	}
 */
}
